﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YArchitech.Controls;
using YArchitech.HVAC;

namespace YArchitech.Plumbing
{
	[Transaction(TransactionMode.Manual)]
	public class TestDc : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIDocument activeUIDocument = commandData.Application.ActiveUIDocument;
			Selection selection = activeUIDocument.Selection;
			Document document = activeUIDocument.Document;
			IEnumerable<Element> enumerable = selection.PickElementsByRectangle("框选水管");
			List<Pipe> list = new List<Pipe>();
			foreach (Element element in enumerable)
			{
				Pipe item = element as Pipe;
				list.Add(item);
			}
			Transaction transaction = new Transaction(document, "水管连接");
			transaction.Start();
			YJKMessageBox.Show(new HYPipeConnect().NewSomeConnect(list).ToString());
			transaction.Commit();
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
